<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<div>
  <input type="text" v-model="num1">
  <input type="text" v-model="num2">
  <input type="button" value="+" @click="f(1)">
  <input type="button" value="-" @click="f(2)">
  <input type="button" value="*" @click="f(3)">
  <input type="button" value="/" @click="f(4)">
  <h3>结果为：<p v-html="result"></p></h3>
</div>
</body>
<script src="js/vue.min.js"></script>
<script>
  let v = new Vue({
    el: "body>div",
    data: {num1: "", num2: "", result: ""},
    methods: {
      f(x) {
        switch (x) {
          case 1:
            v.result = v.num1 * 1 + v.num2 * 1;
            break;
          case 2:
            v.result = v.num1 - v.num2;
            break;
          case 3:
            v.result = v.num1 * v.num2;
            break;
          case 4:
            v.result = v.num1 / v.num2;
            break;
        }
      }
    }
  });
</script>
</html>